import path from 'path';
import { RoutingControllersOptions } from 'routing-controllers';

// 服务接口属性配置
type ServeConfig = {
  port: number;
  host: string;
  prefix: string;
  options: RoutingControllersOptions;
  debug: boolean;
};

/**
 * koa服务配置
 */
const serveConfig: ServeConfig = {
  host: 'localhost',
  port: 3000,
  prefix: '/api/v1',
  options: {
    // cors: true,
    // // 启用校验
    // validation: true,
    // 路由前缀
    routePrefix: '/api/v1',
    // 路由控制器
    controllers: [path.resolve(__dirname, '../controllers/**/*.controller.ts')],
    // 中间件
    middlewares: [path.resolve(__dirname, '../middlewares/**/*.middleware.ts')],
    // 拦截器
    interceptors: [path.resolve(__dirname, '../interceptors/**/*.interceptor.ts')],
  },
  debug: true,
};

export { serveConfig, ServeConfig };
